<?php
/**
  * tframe
  *
  *
  * @copyright Copyright (c) 2012 - 2014, huxiaomin
  * @author huxiaomin    2012-6-29  
  * @since		Version 1.0
  *
  */
  class TTableMs{
  	static $transation = false;
  	
  	//TODO 多个数据的主从。
  	static function startTransation($db=''){
  	   if (!$db){
  	     $db = DDb::Dao();
  	   }
  	   self::$transation = true;
  	   $sql = 'START TRANSACTION';
  	   $db->Query($sql);
  	}
  	
  	static function rollback($db){
  	   if (!$db){
         $db = DDb::Dao();
       }
       self::$transation = true;
       $sql = 'ROLLBACK';
       $db->Query($sql);
       self::$transation = false;
  	}
  	
  	static function commit($db){
  	   if (!$db){
         $db = DDb::Dao();
       }
       self::$transation = true;
       $sql = 'COMMIT';
       $db->Query($sql);
       self::$transation = false;
  	}
  	
  	static function getMs($choose){
  	  if ($choose && !self::$transation){
  	     return DDb::Dao_Slave();
  	  }else {
  	     return DDb::Dao();
  	  }
  	}
    
  
  }  